from flask import Blueprint

from applications.function.data import re_data, rn_data
from applications.function.elv import calculate_risk

import pandas as pd

from version import path

bp = Blueprint('main', __name__)

@bp.route('/cable_segment_grid_data', methods=['GET'])
def cable_segment_grid_data():
    # content = pd.read_excel("D:\\Projects\\risk_api\\file\\线路起止点2.xlsx")
    content = pd.read_excel(path('file', '线路起止点.xlsx'))

    content.columns = ['cable_section_number', 'line_name', 'start', 'end']
    d_list = content.to_dict('records')

    data = {
        "data": d_list
    }
    return data


@bp.route('/cable_segment_data', methods=['GET'])
def cable_segment_data():
    data = {
        "data": re_data()
    }

    return data


@bp.route('/data', methods=['GET'])
def data():
    return rn_data()
